<template>
  <el-dialog v-model="dialogVisible" title="职位详情" width="900" :before-close="handleClose">
    <el-descriptions title="" :column="1" border class="descriptions120">
      <el-descriptions-item label="职位名称">
        {{name_format(data.workTypes)}}
      </el-descriptions-item>
      <el-descriptions-item label="工作地址">
        {{data.workAddress}}
      </el-descriptions-item>
      <el-descriptions-item label="联系人">
        {{data.realName}}
      </el-descriptions-item>
      <el-descriptions-item label="联系电话">
        {{data.userPhone}}
      </el-descriptions-item>
      <el-descriptions-item label="职位状态">
        <el-tag v-if="data.status==0">{{status_format(data.status)}}</el-tag>
        <el-tag type="success" v-else-if="data.status==3">{{status_format(data.status)}}</el-tag>
        <el-tag type="warning" v-else-if="data.status==2">{{status_format(data.status)}}</el-tag>
        <el-tag type="danger" v-else-if="data.status==1">{{status_format(data.status)}}</el-tag>
      </el-descriptions-item>
      <el-descriptions-item label="价格">
        {{data.oneDayWage}}元/天
      </el-descriptions-item>
      <el-descriptions-item label="招工需求">
        <div style="white-space: pre-wrap">{{data.requirement?data.requirement:data.title}}</div>
      </el-descriptions-item>
      <!-- <el-descriptions-item label="预计工期">
        {{data.constructionPeriodDictName}}
      </el-descriptions-item>
      <el-descriptions-item label="用工人数">
        {{data.workNumDictName}}
      </el-descriptions-item> -->
      <el-descriptions-item label="发布身份">
        {{data.userType==0?'个人':"企业"}}
      </el-descriptions-item>
      <el-descriptions-item label="发布时间">
        {{data.gmtCreate}}
      </el-descriptions-item>
      <el-descriptions-item label="审核通过时间">
        {{data.gmtModified}}
      </el-descriptions-item>
    </el-descriptions>
  </el-dialog>
</template>

<script setup lang="ts">
const { proxy } = getCurrentInstance();
let dialogVisible = ref(false);
let statusList = ref([
  { label: "待审核", value: 0 },
  { label: "未通过", value: 1 },
  { label: "正在招", value: 2 },
  { label: "已招满", value: 3 },
]);
let formInline = ref({});
let data = ref({});

let open = async (id) => {
  data.value = await proxy.$apis.pcPostingDetail(id);
  //console.log("详情", data.value);
  dialogVisible.value = true;
};
let name_format = (array) => {
  let list = [];
  array.forEach((element) => {
    list.push(element.name);
  });
  return list.toString();
};
let status_format = (e) => {
  let index = proxy.$utils.findIndexByField(statusList.value, "value", e);
  return statusList.value[index].label;
};
let handleClose = () => {
  dialogVisible.value = false;
};

defineExpose({ open });
</script>

<style lang="scss" scoped>
</style>
